#!/bin/bash

echo "=========================================="
echo "   小型数据库系统 - 运行所有测试"
echo "=========================================="

echo ""
echo "1. Python版本测试"
echo "----------------------------------------"

echo "1.1 Python词法分析器测试:"
cd /Users/zhangpeng/Desktop/150
python3 sql_compiler/lexer.py

echo ""
echo "1.2 Python语法分析器测试:"
cd /Users/zhangpeng/Desktop/150/sql_compiler
python3 parser.py

echo ""
echo "2. C++版本测试"
echo "----------------------------------------"

echo "2.1 C++词法分析器测试:"
cd /Users/zhangpeng/Desktop/150/sql_compiler_cpp
make clean > /dev/null 2>&1
make -f Makefile test_lexer > /dev/null 2>&1
if [ -f "test_lexer" ]; then
    ./test_lexer
else
    echo "词法分析器测试文件未生成，编译主目标..."
    make > /dev/null 2>&1
    ./test_parser
fi

echo ""
echo "2.2 C++语法分析器测试:"
cd /Users/zhangpeng/Desktop/150/sql_compiler_cpp
make test_parser > /dev/null 2>&1
./test_parser

echo ""
echo "2.3 C++文件管理器测试:"
cd /Users/zhangpeng/Desktop/150/storage_system_cpp
make clean > /dev/null 2>&1
make run

echo ""
echo "=========================================="
echo "   所有测试完成！"
echo "=========================================="
